<template>
	<view>
		<view>
			<view>
				<!-- <u-field 
					type="textarea" 
					v-model="remark" 
					label-width="0" 
					label=" " 
					placeholder="请输入备注内容" 
					style="z-index: 100;"
				/> -->
				<textarea style="width: 100%; padding: 20rpx 30rpx; box-sizing: border-box;" rows="5" @input="handleInput"
					:value="remark" placeholder="请输入备注内容" />
			</view>
			<view style="margin: 32rpx;">
				<u-button shape="circle" type="primary" @click="submitRemark">
					确定
				</u-button>
			</view>
		</view>
		<u-top-tips ref="uTips"></u-top-tips>
	</view>
</template>
<script>
	import http from '@/utils/http'
	import api from '@/api'
	export default {
		data() {
			return {
				resume_id: '',
				dataset: [],
				remark: '',
				remark2: '',
				type: 'received'
			}
		},
		onLoad(e) {
			this.resume_id = e.resume_id
			this.type = e.type
		},
		mounted() {
			this.getData()
		},
		methods: {
			handleInput(e) {
				this.remark2 = e.detail.value
			},
			getData() {
				var url = this.type == 'download' ? api.company_downresume_list : api.company_jobapply_list
				http
					.get(url, this.params)
					.then((res) => {
						this.dataset = [...res.data.data.items]
						this.dataset.forEach(element => {
							if (element.resume_id == this.resume_id) {
								this.remark = element.remark
								this.remark2 = element.remark
							}
						})
					})
					.catch(() => {})
			},
			submitRemark() {
				this.remark = this.remark2
				let parmas = {
					remark: this.remark
				}
				parmas.resume_id = this.resume_id
				if (this.remark == '') {
					this.$refs.uTips.show({
						title: '请填写备注内容',
						type: 'error'
					})
					return false
				}
				http
					.post(api.remark_resume, parmas)
					.then((res) => {
						if (res.data.code == 200) {
							this.$refs.uTips.show({
								title: res.data.message,
								type: 'success'
							})
						} else {
							this.$refs.uTips.show({
								title: res.data.message,
								type: 'error'
							})
						}
						setTimeout(() => {
							uni.navigateBack({
								delta: 1
							})
							this.remark = ''
							this.remark2 = ''
						}, 2000)
					})
					.catch(() => {})
			},
		}
	}
</script>
<style lang="scss" scoped>

</style>
